<style lang="scss" src="./index.scss" scoped></style>
<template>
    <div class="tag-list-box">
        <div class="tag-list-label">{{ title }}</div>
        <div class="tag-list-info">
            <ul class="tag-list-ul">
                <template v-for="item in currentList">
                    <li
                        class="tag-list-li"
                        :key="item.value"
                        @click="handleItemClick(item)"
                    >
                        <el-checkbox :value="value.includes(item.value)" style="pointer-events: none">{{item.label || ""}}</el-checkbox>
                    </li>
                </template>
            </ul>
        </div>
    </div>
</template>

<script lang="ts">
import { Component, Vue, Prop, PropSync, Emit } from "vue-property-decorator";

@Component
export default class RelationSelectList extends Vue {
    @Prop({
        type: String,
        default: ""
    })
    readonly title!: string;

    @PropSync("list", {
        type: Array,
        default: () => {
            return [];
        }
    })
    readonly currentList!: any | any[];

    @Prop({
        type: Array,
        default: () => {
            return [];
        }
    })
    readonly value!: any | any[];

    @Emit("item-click")
    handleItemClick(item: any) {
        this.$emit("change", item);
    }
}
</script>
